import {observable, action, /*toJS*/} from 'mobx';
import {Toast,Tools,ListView,Modal} from 'weaver-mobile';
import { RouteLayout } from 'weaver-mobile-page';
import * as API from '../../api/home/remember';
import {toJS} from 'mobx'

const getLabel = Tools.getLabel;


export default class RememberStore {
    @observable loading = false;
    @observable hasRight = '';
    @observable baseRoute = '';

    @observable dateParams = {
        year:'',
        month:''
    };

    @observable rememberGroup = [];
    // @observable currentMonth = {
    //     year: getNow().year,
    //     month: getNow().month,
    // }
    @observable dataSoure = {};
    
    @observable routeData = new RouteLayout.Store({route:this.baseRoute});

    initData = (value={}) =>{
        // this.loading = true;
        // API.getList(value).then( data =>{
        //     this.rememberGroup = data.rememberGroup;
        //     this.loading = false;
        // })
        this.rememberGroup = [
            // { title: '日期' ,workflowid:'',style:"{color:'#969BA6'}" ,key: "data",mark:'0' },
            // { title: '金额' ,workflowid:'',style:"{color:'#969BA6'}" ,key: "money",mark:'0' },
            // { title: '类型' ,workflowid:'',style:"{color:'#969BA6'}" ,key: "type",mark:'2' },
        ];

        this.dataSoure = {
            type:'line',
            // categories:['衬衫', '羊毛衫', '雪纺衫', '裤子'],
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow',
                    snap:true,
                    label:{
                        show:true
                    }
                }
            },
            xAxis: {
                // type: 'category',
                data: [1, 2, 3, 4,5,6,7,8,9,10,11,12],
            },
            yAxis: {
                // type: 'value'
            },
            grid: {
                left: '3%',
                right: '3%',
                bottom: '3%',
                containLabel: true
            }, 
            
            
            series:[
                // {name:'111',data:'34'},
                // {name:'222',data:'28'},
                // {name:'333',data:'25'},
                // {name:'444',data:'40'},
                // {name:'555',data:'36'},
                // {name:'666',data:'19'},
                {
                    type: 'line',
                    name:'金额',
                    data:[34,28,45,69,39,43,33,23,33,39,22,23]
                },
                {
                    type: 'line',
                    name:'笔数',
                    data:[14,29,28,39,25,20,10,13,14,16,8,11]
                },

            ]
        }



    }

    //根据传出来的数据拼接 key - value
    joinObj = (data,k) =>{
        let _obj = {};
        data.map( item =>{
            _obj[item.key] = item[k]
        })
      
        return _obj
    }


    changeRoute = (key) =>{
        this.routeData = new RouteLayout.Store({id:key ,route:this.baseRoute})
    }

    getBaseRoute = (comObj) =>{
        this.comObj = comObj;
        this.baseRoute = comObj.props.match.path;
    }



    
}